<template>
  <div id="app">
    <h1>Vuex-Demo</h1>
    <!-- count: {{ $store.state.count }} <br>
    msg: {{ $store.state.msg }} -->
    count: {{ num }} <br>
    msg: {{ message }}

    <!-- <h2>Getter</h2>
    reverseMsg: {{ $store.getters.reverseMsg }} -->
    <h2>Getter</h2>
    reverseMsg: {{ reverseMsg }}

    <h2>Mutation</h2>
    <!-- <button @click="$store.commit('increate', 2)">Mutation</button> -->
    <button @click="increate(3)">Mutation</button>

    <h2>Actions</h2>
    <!-- <button @click="$store.dispatch('increateAsync', 5)">Actions</button> -->
    <button @click="increateAsync(6)">Actions</button>

    <!-- <h2>Module</h2> -->
    <!-- products: {{ $store.state.products.products }} <br>
    <button @click="$store.commit('setProducts', [])">Module</button> -->
    <!-- products: {{ products }} <br>
    <button @click="setProducts([])">Module</button> -->

    <h2>Strict</h2>
    <button @click="$store.state.msg = 'Lagou'">strict</button>
  </div>
</template>

<script>
// import HelloWorld from './components/HelloWorld.vue'
import { mapActions, mapGetters, mapMutations, mapState } from 'vuex'
export default {
  name: 'App',
  components: {
    // HelloWorld
  },
  computed: {
    // ...mapState(['count', 'msg'])
    ...mapState({
      num: 'count',
      message: 'msg'
    }),
    ...mapGetters(['reverseMsg'])
    // ...mapState('products', ['products'])
  },
  methods: {
    ...mapMutations(['increate']),
    ...mapActions(['increateAsync'])
    // ...mapMutations('products', ['setProducts'])
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
